From: Jan Beulich Date: Mon, 15 Aug 2022 06:53:11 +0000 (+0200) Subject: x86/mm: re-arrange type check around _get_page_type()'s TLB flush X-Git-Tag: archive/raspbian/4.17.0-1+rpi1^2~33^2~313 X-Git-Url: https://dgit.raspbian.org/%22http://www.example.com/cgi/%22/%22http:/www.example.com/cgi/%22?a=commitdiff_plain;h=8eb15275cd5d945acbc0f70a358255dea94117cf;p=xen.git x86/mm: re-arrange type check around _get_page_type()'s TLB flush Checks dependent on only d and x can be pulled out, thus allowing to skip the flush mask calculation. (Also-)Suggested-by: Andrew Cooper Signed-off-by: Jan Beulich Reviewed-by: Andrew Cooper --- diff --git a/xen/arch/x86/mm.c b/xen/arch/x86/mm.c index 40e132b9ba..db1817b691 100644 --- a/xen/arch/x86/mm.c +++ b/xen/arch/x86/mm.c @@ -3020,7 +3020,10 @@ static int _get_page_type(struct page_info *page, unsigned long type, if ( d && shadow_mode_enabled(d) ) shadow_prepare_page_type_change(d, page); - if ( (x & PGT_type_mask) != type ) + if ( (x & PGT_type_mask) != type && + /* Shadow mode: track only writable pages. */ + (!shadow_mode_enabled(d) || + ((x & PGT_type_mask) == PGT_writable_page)) ) { /* * On type change we check to flush stale TLB entries. It is @@ -3035,10 +3038,7 @@ static int _get_page_type(struct page_info *page, unsigned long type, /* Don't flush if the timestamp is old enough */ tlbflush_filter(mask, page->tlbflush_timestamp); - if ( unlikely(!cpumask_empty(mask)) && - /* Shadow mode: track only writable pages. */ - (!shadow_mode_enabled(d) || - ((x & PGT_type_mask) == PGT_writable_page)) ) + if ( unlikely(!cpumask_empty(mask)) ) { perfc_incr(need_flush_tlb_flush); /*